<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <title>MeteoCal - Search results for #{srcBean.search}</title>
        <link href="../css/application.css" rel="stylesheet"></link>
        <link rel="icon" type="image/ico" href="../images/logoico.ico"/>
        <f:metadata>
            <f:viewParam name="src" value="#{srcBean.search}" />
            <f:viewParam name="id" value="#{eBean.newEvent.id}" />
        </f:metadata>
    </h:head>
    <h:body><div id="body">

            <div id="head">
                <a href="personalpage.xhtml"><img src="../images/logo.png" /></a>

                <h:form><p:commandLink action="#{loginBean.logout()}">
                        <p:graphicImage value="../images/logout.png" style="width: 70px; top:140px; left:88%;"/>
                    </p:commandLink></h:form>
            </div>

            <div id="title">
                <p1>MeteoCal</p1><br />
                <p2>Your website to plan your events.</p2>
            </div>

            <div id="bar">
                <a href="personalpage.xhtml" id="ppage" >#{uBean.actualLoggedUser.username} 's MeteoCal</a>
                <a href="calendar.xhtml" id="calendar">Calendar</a>
                <a href="search.xhtml" id="search">Search MeteoCal's friends</a>
            </div>

            <div id="registration"><center><br /><br />
                    Search results for #{srcBean.search}
                    <br /><br /><br />

                    <p:panelGrid class="table" columns="5" >
                    <ui:repeat value="#{srcBean.getSearchedUserExcU(uBean.actualLoggedUser)}" var="user"  >
                        <li>
                               
                            
                                <h:outputText value="#{user}:       " rendered="#{srcBean.resultsFound()}" style="font-family: questrial; font-weight:bold;"/>
                                <h:outputText value="#{uBean.findUser(user).name} #{uBean.findUser(user).surname}     " rendered="#{srcBean.resultsFound()}" style="font-family: questrial;"/>
                                <h:body rendered="#{srcBean.resultsFound()}">
                                    <p:commandButton value="Invite" 
                                                     action="#{iBean.createInvite(user,eBean.newEvent.id, srcBean.search)}" style="list-style: none; border:0; box-shadow:0px 2px 5px #000000;"
                                                 rendered="#{iBean.nonceuninvito(uBean.findUser(user), eBean.eventFromId(eBean.newEvent.id))}"/>
                                <p:commandButton value="Remove" 
                                                 action="#{iBean.deleteInvite(uBean.findUser(user),eBean.eventFromId(eBean.newEvent.id), srcBean.search)}" style="list-style: none; border:0; box-shadow:0px 2px 5px #000000;"
                                                 rendered="#{iBean.ceuninvito(uBean.findUser(user), eBean.eventFromId(eBean.newEvent.id))}">
                                </p:commandButton>
                                </h:body>
                             
                            </li>
                        <br />
                    </ui:repeat>
                    </p:panelGrid>
                    <h:outputText value="No results found" rendered="#{srcBean.noResultsFound()}"/>
                    
                    <br />
                    <p:panelGrid class="table" columns="2">
                    <p:commandButton value="Invite other users" action="#{eBean.invite()}"  
                                     style="border:0; box-shadow:0px 2px 5px #000000; font-size: 19px;">
                <f:param name="id" value="#{eBean.newEvent.id}" />
                    </p:commandButton>
                
                <p:button value="Visualize the event!" outcome="event"
                                           style="border:0; box-shadow:0px 2px 5px #000000; font-size: 19px;">
                    <f:param name="id" value="#{eBean.newEvent.id}" />
                </p:button>
                    </p:panelGrid>
                </center></div>
        </div>      
    </h:body>
</html>
